package com.dianping.cat.consumer.dependency.model.entity;

import com.dianping.cat.consumer.dependency.model.BaseEntity;
import com.dianping.cat.consumer.dependency.model.IVisitor;
import java.util.LinkedHashMap;
import java.util.Map;





public class Segment
  extends BaseEntity<Segment>
{
  private Integer m_id;
  private Integer m_exceptionCount;
/*  17 */   private Map<String, Index> m_indexs = new LinkedHashMap();

/*  19 */   private Map<String, Dependency> m_dependencies = new LinkedHashMap();





  public Segment(Integer id) { this.m_id = id; }




/*  30 */   public void accept(IVisitor visitor) { visitor.visitSegment(this); }


  public Segment addDependency(Dependency dependency) {
/*  34 */     this.m_dependencies.put(dependency.getKey(), dependency);
/*  35 */     return this;
  }

  public Segment addIndex(Index index) {
/*  39 */     this.m_indexs.put(index.getName(), index);
/*  40 */     return this;
  }


  public boolean equals(Object obj) {
/*  45 */     if (obj instanceof Segment) {
/*  46 */       Segment _o = (Segment)obj;

/*  48 */       if (!equals(getId(), _o.getId())) {
/*  49 */         return false;
      }

/*  52 */       return true;
    }

/*  55 */     return false;
  }


/*  59 */   public Dependency findDependency(String key) { return (Dependency)this.m_dependencies.get(key); }



/*  63 */   public Index findIndex(String name) { return (Index)this.m_indexs.get(name); }


  public Dependency findOrCreateDependency(String key) {
/*  67 */     Dependency dependency = (Dependency)this.m_dependencies.get(key);

/*  69 */     if (dependency == null) {
/*  70 */       synchronized (this.m_dependencies) {
/*  71 */         dependency = (Dependency)this.m_dependencies.get(key);

/*  73 */         if (dependency == null) {
/*  74 */           dependency = new Dependency(key);
/*  75 */           this.m_dependencies.put(key, dependency);
        }
      }
    }

/*  80 */     return dependency;
  }

  public Index findOrCreateIndex(String name) {
/*  84 */     Index index = (Index)this.m_indexs.get(name);

/*  86 */     if (index == null) {
/*  87 */       synchronized (this.m_indexs) {
/*  88 */         index = (Index)this.m_indexs.get(name);

/*  90 */         if (index == null) {
/*  91 */           index = new Index(name);
/*  92 */           this.m_indexs.put(name, index);
        }
      }
    }

/*  97 */     return index;
  }


/* 101 */   public Map<String, Dependency> getDependencies() { return this.m_dependencies; }



/* 105 */   public Integer getExceptionCount() { return this.m_exceptionCount; }



/* 109 */   public Integer getId() { return this.m_id; }



/* 113 */   public Map<String, Index> getIndexs() { return this.m_indexs; }





  public void mergeAttributes(Segment other) {
/* 127 */     assertAttributeEquals(other, "segment", "id", this.m_id, other.getId());

/* 129 */     if (other.getExceptionCount() != null) {
/* 130 */       this.m_exceptionCount = other.getExceptionCount();
    }
  }


/* 135 */   public Dependency removeDependency(String key) { return (Dependency)this.m_dependencies.remove(key); }



/* 139 */   public Index removeIndex(String name) { return (Index)this.m_indexs.remove(name); }


  public Segment setExceptionCount(Integer exceptionCount) {
/* 143 */     this.m_exceptionCount = exceptionCount;
/* 144 */     return this;
  }

  public Segment setId(Integer id) {
/* 148 */     this.m_id = id;
/* 149 */     return this;
  }

  public Segment() {}
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/lib/cat-consumer-3.0.0.jar!/com/dianping/cat/consumer/dependency/model/entity/Segment.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */